home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 1
/
CU Amiga Magazine CD-ROM Special Edition (1995)(EMAP Images)(GB)[Issue 1995-11].iso
/
Aminet
/
misc
/
emu
/
SaveNames1_2.lha
/
SaveNames1.2
/
SaveNames.doc
< prev
next >
Wrap
Text File
|
1995-06-10
|
12KB
|
281 lines
Copyright (why not...)
----------------------
SaveNames v1.2 software and documentation are copyrighted © 1995 by
Marcin Orlowski. All Rights Reserved.
Distribution (pirate or die!)
-----------------------------
Freely distributable in complete archive with following files included:
SaveNames.c - source code
SaveNames.c.info - source icon
SaveNames.doc - this documentation
SaveNames.doc.info - documentation icon
SaveNames.man - this documentation in UNIX's man format
SaveNames - Amiga executable
SaveNames.info - Amiga executable icon
SD!.displayme - our BBS info
Disclaimer (as always :)
------------------------
No responsibility or liability will be accepted for any damage that
may appear to have resulted from use of this program. All use is at
your own risk. The software is provided "as is" without any warranty
implied or otherwise to the fitness or accuracy of the software and
documentation. The author reserves the right to update the software
and/or documentation without notice.
Usage (what is it!?)
--------------------
Some people (like me) are forced to use pee-cee machines to transfer
files from internet to my Amiga (it doesn't mean I've bought a pc
for my own! I use (big word:) it only at my technical university).
As you all know, no one needs more chars to name his files than 8.3,
which seems to be a 'professional filename format'. Any other, longer
names are obsolete and should be forbidden. Unfortunately both Amiga
and Unix based machines use longer names for their files, so
transfering files between those platforms via pc causes 90% of name
(mainly dots :) to be eaten by pc. So I decided to cure this.
SaveNames is the medicine against. What does it do? Lets say, you want
to transfer some files stored in directory 'MyFiles' on your Unix
account to Amiga via pc floppies. Files use 'obsolete' names:
kickstart
KICKdisk.info
kickstart.info
So before you start to copy them to disk type:
SaveNames C MyFiles
and names of all files in this directory are converted ('C' means
'CODE' and may be lowercase or mixedcase) to less than 8 chars (suffix
'PCP' (pc protection :) will also be added to allow you easily detect
those files, or automate decoding e.g. via DOpus FileClass. If you use
DOpus set class checking to: "MATCHNAME WFMHFile.idx OR MATCHNAME #?.pcp"
and operation to "(AmigaDos) SaveNames D {s}" and you will decode files
by doubleclick.). Phew, you said? No big deal? pc does it itself! Bet it
doesn't. If you look in your 'MyFiles' drawer you'll find the new file
named 'WFMHFile.idx' looking like that:
7204094 kickstart
720704c KICKdisk.info
72085c4 kickstart.info
Got it? Yes! Those data are used to restore filenames after whole
transfer on destination machine. How to do this? Copy transfered files
from pc disks to one directory on your Amiga disk (e.g. 'MyFilesToo')
and type:
SaveNames D MyFilesToo
This time command 'D' means 'Decode'. Program opens file index
described below and renames all known (stored in index) files back
to theirs original names. Simple? Yes, it is. And it works too!
NOTES: Command 'D' has special, expanded mode, activating by '-'
as command prefix: '-D'. See 'Technical Info' chapter to find
out what this feature is for.
While names coding SaveNames shows you estimated number of disks
you will need to store all your crypted files on. If you want
do this calculation without main code process use '-C' command
instead of 'C'
Requirements
------------
Something with Intel outside, few bytes of free memory, files to eat,
2 busty babes and 1 big beer.
Technical info (sounds soooo wise... :)
---------------------------------------
Portability is base idea of this project, so SaveNames is written in
plain ANSI C and may be simply compiled on any machine. If you find any
problems, let me know! And do not compile it on pc - it doesn't have any
sense... :)
Unfortunately small changes, as always, have to be done before you run
the compiler, so look into the source, and select your platform (for
now AMIGA, UNIX (being honest IRIX) and LINUX is checked and supported.
If you port it to Mac world let me know and send changes to me (in this
case please do only small GUI). AMIGA side was tested on my A4000, UNIX
platform was tested on SILICON GRAPHICS' IRIS INDIGO and HP. LINUX side
was tested on... LINUX side :-)
Name encoding is done in two passes. 1st pass - scanning directory
and building coded names, 2nd pass renaming files and writting
index file. It has to be done this way, because scanning directory
while it is changing, may (and in 99% it does) put the program in the
infinite loop. Sometimes we may also miss some files. Decoding is done
in one pass.
Starting to decode, program tries to read index file first. First it
tries to open file named 'WFMHFile.idx'. If file couldn't be found,
it tries to open file again, with name in lowercase and if it fails
to, the last try use uppercased name. This is important mainly for
Unix side, because Unix is case-sensitive. So if you transferred
your files via pc, the names may be 'fixed' to lower or uppercase.
While decoding, program may do the same trick with files to decode,
but this feature is defaulty off, which means that only one try is
attemped, and filenames are supposed to be exactly the same as while
coding. Use '-D' instead of 'D' to turn this mode on.
You may convert as many file names as you wish, because there's no
static arrays, but dynamicaly build list. You are only limited by your
memory. To code 1000 names you will need, on Amiga, about 266KB. Why
only 266KB? Because every name is stored in a list's entry containing
pointer to next entry (on 32bit machines it takes 4 bytes), converted
name (12 chars + trailing zero) and original file name. The size of last
entry depends on your system. In your system includes, you will find
definition of MAXNAMELEN, which limits max length of filename. On Amiga
it's set to 255 chars. For now it's too much, because you cannot use names
longer than 30 chars (because there's no more free bytes on disk block).
So if you are REALLY out of memory, you may change this by hand (see
included source). Safe value is 108, because system structure
FileInfoBlock reserves exactly 108 bytes for filename. You may save then
few bytes. E.g. for those 1000 files mentioned above, with MAXNAMELEN
set to 30 you will save 248KB, with MAXNAMELEN set to 108, only :) 145
KB but think what are you doing! You probably never code more than 100
names in one session and you surely do not use A1000 with 256 KB RAM. So
better leave MAXNAMELEN alone...
You may ask: How do you code filenames to those weird numbers, pal?
I answer: I do not code it at all! I'm just copying file's own INode
(it's kind of FileHandle on Unix machines). Because all filesystems
use almost the same algorithms, it also use INodes without any tricks
(maybe pc does it different, but who cares pc?). Sometimes it is
called INode, sometimes FileHandle and sometimes BlahBlahBlah, but
it always means the same - almost unique number belongs to file.
On Amiga side I could use GetUniqueID() from utility.library, but
it is available under OS3.0 and newer and, what is more important,
generates only 4294967295 unique numbers. That's all.
Bugs (eep...)
-------------
Program doesn't recognize if name belongs to directory or to file and
treats all the same. For now, it also can't scan directories
recursively. Solution: do not create subdirs in drawer you want
SaveNames to process.
There may appear some problems if you will have two files in the dir,
being in fact links to other file. In this case INode will be the
same. Solution: use proper file instead of its shadows.
You must _not_ have file named 'WFMHFile.idx' in your drawer, because
while encoding/decoding it's written/read sequentially. So while
encoding it may be overwriten (but not if it is 1st file
in directory :). While decoding it will be skipped, because of
already opened (being in use) file with the same name. Solution:
rename your file :)
On Amiga side it doesn't work when called from WB. If I find some spare
time I maybe add this, but I am not quite sure it's really needed.
If you have transferred this archive from Unix account to your
machine via pc, you have probably noticed that few letters have been
eaten.. You should use... SaveNames to avoid it! :)
Some older compilers requires the function to be declared in old C&R
style (see the source if you don't know what it's about). If you are
own such a compiler, simply uncommet the OLD_STYLE definition befor
you start to compile the program.
Future plans (wow!)
-------------------
If someone finds a reason to decode single files too, I will add this
feature on request, bacause it's easy to do... :)
I also may add WB handling, but I don't think anybody needs this.
Recursive directory scanning.
History (what has happen to the Sherlock Holmes in the past)
------------------------------------------------------------
* v1.0 - Initial release
Worldwide distribution
SaveNames-mania....
* v1.1 - WARNING: Internal format of the 'WFMHFile.idx'
has been changed! Better decode all old stuff
before you install this release!
Changes:
- LINUX and gcc differences and needs supported
- Unnecessary %ld's replaced by %d's
- SaveNames could not find the index file on Unix
side if its name was 'processed' by pc (see doc)
Reported by Niklas Edmundsson
- Added old C&R function declaration for older compilers
(this feature is switchable and defaulty is off)
- SaveNames will not remove 'WFMHFile.idx' index file
if restoring was not 100% successed
Sugested by Konrad Dubiel
* v1.2 - Expand decoding mode added (see 'Technical Info').
- Solved problems with names contain spaces (this was
the main reason I've changed the index file format).
- SaveNames can now calculate number of disks you will
need to store contents of your dir on floppies
(both for Amiga and pc disks) and number of bytes
left free on the last diskiette.
- New command '-C' ('-COUNT') added, which scans given
directory and counts total length of files and
floppy disk usage (while coding, those information
will also be shown).
- Source slightly rewritten.
Author (it's me, it's me)
-------------------------
Marcin Orlowski
ul. Radomska 38
71-002 Szczecin
Poland
E-Mail: carlos@felix.univ.szczecin.pl
FidoNet: Marcin Orlowski@2:481/22.2
GlobalNet: Marcin Orlowski@52:4800/6
--------------------- C O M M E R C I A L B R E A K --------------------
______ __ __
/ ____//_/ / / Find your way to the smallest & slowest
/ /___ __ / / __ __ ______ _____
/___ // / / / / / / // ____// .__/ BBS in central Europe !!!
____/ // /_ / /_ / /_/ // __/_ / /
/_____//___//___/ \____//_____//_/ W.F.M.H. support
__
____ GlobalNET: 52:4800/6 __ / /
+48 91 540431 / __ \ FidoNET: 2:481/22.2 / / \/
/ / / /_____ ______ ______ _ _ / / ______
24 Hours / Day / / / // .__// ____// __ // \_/ \ /_/ / ____/
/ /_/ // / / __/_ / __ // /__/ / __ _\__ /
1200-19200 bps /_____//_/ /_____//_/ /_//_/ /_/ /_/ /_____/
Serving on A3000, 2CDTVs, 2A500+, 5 additional CD-ROMs on-line
For all Amigas, Macs and C64